package com.ycy.chuwenuniapp.controller;

import com.ycy.chuwenuniapp.common.ResData;
import com.ycy.chuwenuniapp.dto.GoodsTypeDto;
import com.ycy.chuwenuniapp.service.GoodsTypeService;
import com.ycy.chuwenuniapp.vo.GoodsTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "商品分类管理")
@RequestMapping("/goodsType")
@RestController
public class GoodsTypeController {
    @Resource
    private GoodsTypeService goodsTypeService;

    @PostMapping("/save")
    @ApiOperation("增加或修改")
    public ResData<Boolean> saveGoodsType(@RequestBody GoodsTypeDto goodsTypeDto) {
        return goodsTypeService.saveGoodsType(goodsTypeDto);
    }

    @GetMapping("/findAll")
    @ApiOperation("查询全部")
    public ResData<List<GoodsTypeVo>> findAll(String name) {
        return goodsTypeService.findAll(name);
    }

    @DeleteMapping("/delete")
    @ApiOperation("单个删除")
    public ResData<Boolean> delete(String id) {
        return goodsTypeService.delete(id);
    }
}
